package com.fitns.user.mapper.baseConfig;

import static com.fitns.user.mapper.baseConfig.TbStaffWorkInfractionDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbStaffWorkInfraction;
import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbStaffWorkInfractionMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbStaffWorkInfraction> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbStaffWorkInfractionResult")
    TbStaffWorkInfraction selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbStaffWorkInfractionResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="person", property="person", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="organ_id", property="organId", jdbcType=JdbcType.BIGINT),
        @Result(column="lgitude", property="lgitude", jdbcType=JdbcType.VARCHAR),
        @Result(column="latitude", property="latitude", jdbcType=JdbcType.VARCHAR),
        @Result(column="warn_type", property="warnType", jdbcType=JdbcType.VARCHAR),
        @Result(column="warn_range", property="warnRange", jdbcType=JdbcType.VARCHAR),
        @Result(column="warn_way", property="warnWay", jdbcType=JdbcType.VARCHAR),
        @Result(column="location", property="location", jdbcType=JdbcType.CHAR),
        @Result(column="real_id", property="realId", jdbcType=JdbcType.BIGINT),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TbStaffWorkInfraction> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(tbStaffWorkInfraction);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbStaffWorkInfraction);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbStaffWorkInfraction)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbStaffWorkInfraction record) {
        return insert(SqlBuilder.insert(record)
                .into(tbStaffWorkInfraction)
                .map(person).toProperty("person")
                .map(phone).toProperty("phone")
                .map(organId).toProperty("organId")
                .map(lgitude).toProperty("lgitude")
                .map(latitude).toProperty("latitude")
                .map(warnType).toProperty("warnType")
                .map(warnRange).toProperty("warnRange")
                .map(warnWay).toProperty("warnWay")
                .map(location).toProperty("location")
                .map(realId).toProperty("realId")
                .map(inputTime).toProperty("inputTime")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbStaffWorkInfraction record) {
        return insert(SqlBuilder.insert(record)
                .into(tbStaffWorkInfraction)
                .map(person).toPropertyWhenPresent("person", record::getPerson)
                .map(phone).toPropertyWhenPresent("phone", record::getPhone)
                .map(organId).toPropertyWhenPresent("organId", record::getOrganId)
                .map(lgitude).toPropertyWhenPresent("lgitude", record::getLgitude)
                .map(latitude).toPropertyWhenPresent("latitude", record::getLatitude)
                .map(warnType).toPropertyWhenPresent("warnType", record::getWarnType)
                .map(warnRange).toPropertyWhenPresent("warnRange", record::getWarnRange)
                .map(warnWay).toPropertyWhenPresent("warnWay", record::getWarnWay)
                .map(location).toPropertyWhenPresent("location", record::getLocation)
                .map(realId).toPropertyWhenPresent("realId", record::getRealId)
                .map(inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbStaffWorkInfraction>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, id, person, phone, organId, lgitude, latitude, warnType, warnRange, warnWay, location, realId, inputTime)
                .from(tbStaffWorkInfraction);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbStaffWorkInfraction>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, id, person, phone, organId, lgitude, latitude, warnType, warnRange, warnWay, location, realId, inputTime)
                .from(tbStaffWorkInfraction);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbStaffWorkInfraction selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, id, person, phone, organId, lgitude, latitude, warnType, warnRange, warnWay, location, realId, inputTime)
                .from(tbStaffWorkInfraction)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbStaffWorkInfraction record) {
        return UpdateDSL.updateWithMapper(this::update, tbStaffWorkInfraction)
                .set(person).equalTo(record::getPerson)
                .set(phone).equalTo(record::getPhone)
                .set(organId).equalTo(record::getOrganId)
                .set(lgitude).equalTo(record::getLgitude)
                .set(latitude).equalTo(record::getLatitude)
                .set(warnType).equalTo(record::getWarnType)
                .set(warnRange).equalTo(record::getWarnRange)
                .set(warnWay).equalTo(record::getWarnWay)
                .set(location).equalTo(record::getLocation)
                .set(realId).equalTo(record::getRealId)
                .set(inputTime).equalTo(record::getInputTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbStaffWorkInfraction record) {
        return UpdateDSL.updateWithMapper(this::update, tbStaffWorkInfraction)
                .set(person).equalToWhenPresent(record::getPerson)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(lgitude).equalToWhenPresent(record::getLgitude)
                .set(latitude).equalToWhenPresent(record::getLatitude)
                .set(warnType).equalToWhenPresent(record::getWarnType)
                .set(warnRange).equalToWhenPresent(record::getWarnRange)
                .set(warnWay).equalToWhenPresent(record::getWarnWay)
                .set(location).equalToWhenPresent(record::getLocation)
                .set(realId).equalToWhenPresent(record::getRealId)
                .set(inputTime).equalToWhenPresent(record::getInputTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbStaffWorkInfraction record) {
        return UpdateDSL.updateWithMapper(this::update, tbStaffWorkInfraction)
                .set(person).equalTo(record::getPerson)
                .set(phone).equalTo(record::getPhone)
                .set(organId).equalTo(record::getOrganId)
                .set(lgitude).equalTo(record::getLgitude)
                .set(latitude).equalTo(record::getLatitude)
                .set(warnType).equalTo(record::getWarnType)
                .set(warnRange).equalTo(record::getWarnRange)
                .set(warnWay).equalTo(record::getWarnWay)
                .set(location).equalTo(record::getLocation)
                .set(realId).equalTo(record::getRealId)
                .set(inputTime).equalTo(record::getInputTime)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbStaffWorkInfraction record) {
        return UpdateDSL.updateWithMapper(this::update, tbStaffWorkInfraction)
                .set(person).equalToWhenPresent(record::getPerson)
                .set(phone).equalToWhenPresent(record::getPhone)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(lgitude).equalToWhenPresent(record::getLgitude)
                .set(latitude).equalToWhenPresent(record::getLatitude)
                .set(warnType).equalToWhenPresent(record::getWarnType)
                .set(warnRange).equalToWhenPresent(record::getWarnRange)
                .set(warnWay).equalToWhenPresent(record::getWarnWay)
                .set(location).equalToWhenPresent(record::getLocation)
                .set(realId).equalToWhenPresent(record::getRealId)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}